<#--
  Service 查询条件构建方法
  
  根据字段类型和名称智能选择查询方式：
  - Date/Time: 范围查询 (ge/le)
  - String (code/no/id): 精确查询 (eq)
  - String (其他): 模糊查询 (like)
  - 其他类型: 精确查询 (eq)
-->

    /**
     * 构建查询条件
     *
     * @param queryDTO 查询DTO
     * @return 查询Wrapper
     */
    private LambdaQueryWrapper<${table.entityName}> buildQueryWrapper(${table.entityName}DTO queryDTO) {
        LambdaQueryWrapper<${table.entityName}> wrapper = new LambdaQueryWrapper<>();
        
        if (queryDTO == null) {
            return wrapper;
        }
        
        // 根据字段类型和名称智能选择查询方式
<#list columns as c>
  <#if c.propertyName?? && c.propertyName != "id">
    <#assign skipField = false>
    <#if c.columnName?? && (c.columnName?lower_case == "tenant_id" || c.columnName?lower_case == "create_by" || c.columnName?lower_case == "create_time" || c.columnName?lower_case == "create_date" || c.columnName?lower_case == "update_by" || c.columnName?lower_case == "update_time" || c.columnName?lower_case == "update_date" || c.columnName?lower_case == "deleted" || c.columnName?lower_case == "version")>
      <#assign skipField = true>
    </#if>
    <#if !skipField>
      <#if c.javaType?? && (c.javaType?contains("Date") || c.javaType?contains("LocalDateTime") || c.javaType?contains("LocalDate") || c.javaType?contains("Timestamp"))>
        // ${c.comment!(c.propertyName!'')} - 时间范围查询
        wrapper.ge(queryDTO.get${c.propertyName?cap_first}Start() != null, ${table.entityName}::get${c.propertyName?cap_first}, queryDTO.get${c.propertyName?cap_first}Start());
        wrapper.le(queryDTO.get${c.propertyName?cap_first}End() != null, ${table.entityName}::get${c.propertyName?cap_first}, queryDTO.get${c.propertyName?cap_first}End());
      <#elseif c.javaType?? && (c.javaType?contains("String") || c.javaType == "String")>
        <#-- 根据字段名判断是精确查询还是模糊查询 -->
        <#if c.propertyName?lower_case?ends_with("code") || c.propertyName?lower_case?ends_with("no") || c.propertyName?lower_case?ends_with("id")>
        // ${c.comment!(c.propertyName!'')} - 精确查询
        wrapper.eq(StringUtils.hasText(queryDTO.get${c.propertyName?cap_first}()), ${table.entityName}::get${c.propertyName?cap_first}, queryDTO.get${c.propertyName?cap_first}());
        <#else>
        // ${c.comment!(c.propertyName!'')} - 模糊查询
        wrapper.like(StringUtils.hasText(queryDTO.get${c.propertyName?cap_first}()), ${table.entityName}::get${c.propertyName?cap_first}, queryDTO.get${c.propertyName?cap_first}());
        </#if>
      <#else>
        // ${c.comment!(c.propertyName!'')} - 精确查询
        wrapper.eq(queryDTO.get${c.propertyName?cap_first}() != null, ${table.entityName}::get${c.propertyName?cap_first}, queryDTO.get${c.propertyName?cap_first}());
      </#if>
    </#if>
  </#if>
</#list>
        
        return wrapper;
    }


